package interfaz2;

import java.io.FileNotFoundException;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import core.Util;

import dustconf.DustConf;

/**
 * The dialog that will pop-up when the "About" ToolItem is selected.
 * 
 * @author ole
 */
public class AboutDialog extends DustDialog {
	
	/**
	 * Class constructor.
	 * @param parent:
	 * 		The Shell where this dialog will be shown.
	 * @throws FileNotFoundException
	 */
	public AboutDialog(Shell parent) throws FileNotFoundException {
		super(parent);
		
		Composite comp;
		GridData grid;
		Label label;
		Text text;
		String images_path;
		
		shell.setText("About Dust");
		images_path = Util.checkDirectoryPath(DustConf.getImagesFolder());
		
		// The main Composite.
		comp = new Composite(shell, SWT.BORDER);
		comp.setLayout(new GridLayout(1, true));
		grid = new GridData(SWT.TOP, SWT.LEFT, true, true);
		comp.setLayoutData(grid);
		
		// A label with the I64 logo.
		label = new Label(comp, SWT.CENTER);
		grid = new GridData(SWT.FILL, SWT.FILL, true, true);
		label.setLayoutData(grid);
		label.setText("Dust");
		label.setImage(IfaceUtils.buildImage(images_path + "logo-i64.png"));
		
		// The text below the logo.
		text = new Text(comp, SWT.MULTI | SWT.CENTER);
		grid = new GridData(SWT.FILL, SWT.FILL, true, true);
		text.setLayoutData(grid);
		text.setEditable(false);
		text.setText("");
		text.append("http://www.informatica64.com\r\n");
		text.append("\r\n");
		text.append("Authors:\r\n");
		text.append("Chema Alonso\r\n");
		text.append("Alejandro Martín\r\n");
		text.append("David Luengo\r\n");
		text.append("Alejandro Nolla\r\n");
		text.append("Ignacio Briones\r\n");
		text.append("Rodolfo Bordón\r\n");
		text.append("\r\n");
		text.append("Suggestions are welcome at dust@informatica64.com");
		
		comp.pack();
	}
}
